#!/bin/bash
FILES=$(find -type f -name "*.bin")
for FILE in $FILES; do
  IFS="./" read -a PARTS <<< "$FILE"
  PRINTER="${PARTS[3]}"
  OP="${PARTS[4]}"
  BINS=$(find -type f -name "$PRINTER\.$OP.*\.bin")
  if [ ! -x "$BINS" ]; then    
    TO_KILL=$(du -ab $BINS | sort -nr | tail -n+2 | cut -f2)
    if [ ! -z "$TO_KILL" ]; then
      rm $TO_KILL
    fi
  fi
done
